import axios from 'axios'
import { getStudentList, getStudent, addStudent, deleteStudent, updateStudent, uploadFile, uploadFileAudio, uploadFileVideo } from '@/api/student'

// 创建axios实例
const service = axios.create({
  baseURL: '/api', // 改为相对路径
  timeout: 5000 // 请求超时时间
})

// 请求拦截器
service.interceptors.request.use(
  config => {
    // 在这里可以添加token等请求头
    // config.headers['Authorization'] = getToken()
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

// 响应拦截器
service.interceptors.response.use(
  response => {
    return response.data
  },
  error => {
    return Promise.reject(error)
  }
)
export const http = service
// 统一导出API方法
export default {
  student: {
    getStudentList,
    getStudent,
    addStudent,
    updateStudent,
    deleteStudent,
    uploadFile,
    uploadFileAudio,
    uploadFileVideo
  },
}
